/*
 * @Author: firefly717
 * @Date: 2024-06-22 10:11:13
 * @LastEditTime: 2024-06-22 19:45:57
 * @Description: 普通类
 */

import 'models/Person.dart';

void main() {
  var p0 = Person('小明', 18, nickName: "tony");
  print(p0.toString());

  // 比较运算
  var p1 = Person('小明', 18, nickName: "tony");
  print("p1和p0是否相等：${p1 == p0}");
  print(p1.toString());

  // copy操作,age: 33
  final p2 = p0.copyWith(name: '静静', sex: Sex.female, nickName: "lucy");
  print(p2.toString());
  // 访问会报错
  // print(p2._age);
  // p2.age = 12;
  // p2._secret();
  print("${p2.name}的年龄为：${p2.age}");
  print("");

  // 工厂构造方法
  final p3 = Person.template("无名氏", 32);
  if (p3.isOld()) {
    print("扎心了老铁");
    print(p3.toString());
  }
  final p4 = Person.template("无名氏", 32);
  print(p4.toString());

  print("p3和p4是否相等：${p3 == p4}");
}
